//路由管理
(function($){
    $(function(){
        var resizePage = (function () {
            $("body , .compnode-page").height($(window).height());
            var ww = $(window).width(),
                wh = $("body").innerHeight(),
                searchH = $(".search-panel").outerHeight(true),
                footerH = $(".table-footer").outerHeight(true),
                ulHeaderH = $(".ul_head").outerHeight(true),
                $ulBody = $(".ul_body");

            $ulBody.height(wh -  searchH - footerH - ulHeaderH);
            return arguments.callee;
        })();
        $(window).resize(resizePage);
        
        var top = window.parent.parent;

        $(".ul_table")
        //展开状态下拉搜索栏
            .on("click",".state-search",function(){
                if($(this).hasClass("up")){
                    $(this).removeClass("up");
                    $(this).closest(".state-panel").removeClass("on");
                }else{
                    $(this).addClass("up");
                    $(this).closest(".state-panel").addClass("on");
                }
                //点击页面其他区域隐藏状态下拉
                $(document).on("click.state",function(e){
                    var evt = e.target;
                    if ($(evt).closest(".state-panel").length == 0) {
                        $(".state-search").removeClass("up");
                        $(".state-panel").removeClass("on");
                        $(document).off("click.state");
                    }
                })
                //按状态搜索
                    .on("click",".state-select li",function(e){
                        e.stopPropagation();
                        $(".state-select").find(".select_option").removeClass("active");
                        $(".state-search").removeClass("up");
                        $(this).closest(".state-panel").removeClass("on");
                        $(this).addClass("active");
                        //stateType的值为(1,2,3,4)分别对应(全部，运行中，已关机，错误)
                        var stateType = $(this).attr("sid");
                        console.log(stateType);
                    })
            })

        //
        $(".li_tr.mount")
        //挂载
            .on("click",".td_btn",function(){
                top.$.popShow("pages/storageManage/mount_storage.html");
            })

        //分页		
        var initPagination = function() {
            var total_page = 50;
            $("#pagination").pagination(total_page,{
				items_per_page : 10,
				prev_text:"上一页",
	            next_text:"下一页",
	            num_edge_entries : 3,
	            ellipse_text : '...',
	            num_display_entries : 5	,
	            callback: page_callback,
	            link_to : 'javascript:void(0)'
			});
        }();
        //分页点击回调
        function page_callback(page_index, jq){
            return false;
        }

    })
})(jQuery)
